package com.xiaohui.gwc.controller;

import com.xiaohui.gwc.mode.Result;
import com.xiaohui.gwc.mode.Upload;
import com.xiaohui.gwc.service.ProductService;
import com.xiaohui.gwc.service.ProductsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: Poppin
 * @Date: 2021/11/30 13:41
 * @Version: 1.0
 */
@RestController
@RequestMapping("/pro")
public class ProductController {


    ProductService productService;
    @Autowired
    public void setProductService(ProductService productService){
        this.productService = productService;
    }

    ProductsService productsService;
    @Autowired
    public void setProductsService(ProductsService productsService){
        this.productsService = productsService;
    }

    @GetMapping("/product")
    public Result product(@RequestParam("id")Integer id){
        return productService.product(id);
    }

    @GetMapping("/products")
    public Result productsAll(@RequestParam("current")Integer cu){
        return productsService.getAllProduct(cu);
    }
    @GetMapping("/category")
    public Result Category(@RequestParam("cate")String Cate){
        return productsService.getCategory(Cate);
    }

    @GetMapping("/search")
    public Result Search(@RequestParam("name")String name){
        return productsService.getLikeProduct(name);
    }

    @PostMapping("/up")
    public Result UP(@RequestBody Upload upload){
        return productsService.Upload(upload);
    }

    @GetMapping("/getRD")
    public Result getRd(){
        return productsService.getRdAll();
    }

}
